package tests_mason;

import java.awt.Paint;

import sim.app.physicsTutorial1.PhysicsTutorial1;
import sim.engine.SimState;
import sim.engine.Steppable;
import sim.physics2D.physicalObject.MobileObject2D;
import sim.physics2D.util.Angle;
import sim.util.Double2D;

/**
 * testing the construction of a robot.
 * @author fernando
 *
 */
public class TestRobot extends MobileObject2D implements Steppable {

	public TestRobot(Double2D pos, Double2D vel, double width, double height, Paint paint){
		// initial position and velocity
		this.setVelocity(vel);
		this.setPose(pos, new Angle(0));

		// shape - determines how the object will look and how collision detection is done
		this.setShape(new sim.physics2D.shape.Rectangle(width, height, paint), width * height);

		// physical properties
		/**
		 * The last two method calls set some physical parameters for the object. 
		 * The "Coefficient of Friction" tells the simulator how easily the objects
		 *  slides over the background. A value of "0" means that the object is 
		 *  perfectly slippery - kind of like a puck on ice. As the value for the 
		 *  friction coefficient increases the object gets less slippery. 
		 *  The "Coefficient of Restitution" determines how elastic the 
		 *  object is - how hard it rebounds from collisions. A value of 1 
		 *  indicates perfect elasticity (like a super ball), while a value of 0 
		 *  means the object is totally inelastic (like a flat basketball). After 
		 *  getting the simulation working, try playing around with different 
		 *  values for these two coefficients
		 */
		this.setCoefficientOfFriction(0);
		this.setCoefficientOfRestitution(1);
	}

	@Override //steppable
	public void step(SimState state) {
		Double2D position = this.getPosition();
		PhysicsTutorial1 simPhysicsTutorial1 = (PhysicsTutorial1) state;
		simPhysicsTutorial1.fieldEnvironment.setObjectLocation(this, new sim.util.Double2D(position.x, position.y));		
	}

}
